import Http from '../utils/request'

class PaihaoService extends Http {

  // 排号
  createPaihao = (params) => {
    return this.post('/queue/add', params);
  }

  // 查看今日排号情况
  paihaoInfo = (busiType) => {
    return this.get(`/queue/today/${busiType}`);
  }

  //查询预约号队列
  queryTemporaryQueueList = (data) => {
    return this.post('/queue/temporary', data)
  }

  //客户获取自己的排号信息
  myPaihaoInfo = (params) => {
    const url = `/queue/my/${params.mobile}/${params.verifycode}`
    return this.get(url)
  }

  queryBusinessAndAppointmentType = () => {
    return this.all([this.queryBusinessType(), this.queryAppointmentType()])
  }
  //获取业务类型
  queryBusinessType = () => {
    return this.post('/sysbusitype/querySysBusiTypeData');
  }
  // 获取预约类型
  queryAppointmentType = () => {
    //TODO 修改url
    return this.get('/appointmentType');
  }

  // 叫号
  call = (code) => {
    return this.get(`/xf/tts/${code}`)
  }
  //查询当前&当日排号列表
  queueList = (data) => {
    return this.post(`/queue/time_slot/list`, data)
  }

  //取消自己的排号
  queueCancel = (data) => {
    const url = `/queue/cancel/${data.id}`
    return this.get(url)
  }

  // 业务员修改当前服务状态
  busiServerStatusManage = (queueId, windowId, type) => {
    if (type === '5') {
      // 服务完成
      return this.busiServerOver(queueId, windowId)
    } else if (type === 'serviceCancel') {
      // 服务取消
      return this.busiServerCancel(queueId, windowId)
    } else if (type === '4') {
      // 服务取消
      return this.busiServerStart(queueId, windowId)
    } else if (type === '6') {
      // 服务取消
      return this.busiServerSkip(queueId, windowId)
    }

  }



  // 业务员——服务完成
  busiServerOver = (queueId, windowId) => {
    return this.get(`/busi/process/complete/${queueId}/${windowId}`)
  }
  // 业务员——开始服务
  busiServerStart = (queueId,windowId) => {
    return this.get(`/busi/process/start/${queueId}/${windowId}`)
  }

  // 业务员——跳过服务
  busiServerSkip = (queueId, windowId) => {
    return this.get(`/busi/process/skip/${queueId}/${windowId}`)
  }

  // 业务员——取消服务
  busiServerCancel = (queueId, status) => {
    return this.postForm('/biz/staff_cancel', { bizId: queueId, bizStatus: status })
  }

  // 获取当前用户信息
  getAccountByToken = (token) => {
    return this.get(`/window/getAccountByToken?token=${token}`)
  }

  //获取当前业务ID下31天内的预约情况
  get31DayQueueInfoForBusinessId = (businessId) => {
    return this.get('/date/queue/status/' + businessId);
  }

  //获取业务类型
  queryBusinessTypeName = (businessId) => {
    return this.post('/sysbusitype/getbusitypesinglebyid/' + businessId);
  }

  //获取当前业务开启的时段
  getTimeSlotQueueInfoForBusinessIdAndDate = (businessId, date) => {
    return this.get('/time_slot/enable/' + businessId + '/' + date);
  }

  //给窗口分配一个号为已分配
  dispatch = (data) => {
    return this.post(`/busi/process/auto/dispatch`, data)
  }
  /**
   * dispatchId:要跳过的bbusinessId，
   * unDispatchId：要处理的businessId
   * windowId：窗口ID
   */
  dispatchAndSkipCurrentItem = (dispatchId,unDispatchId,windowId) => {
    return this.get(`/busi/process/manual/dispatch/${dispatchId}/${unDispatchId}/${windowId}`)
  }
}

export default new PaihaoService()
